package org.example.repository.dialect.mysql;

import org.example.repository.Entity;
import org.example.repository.Repository;
import org.example.repository.RepositoryFactory;
import org.example.repository.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;

public class MysqlRepositoryFactory implements RepositoryFactory {

    private final JdbcTemplate jdbcTemplate;

    public MysqlRepositoryFactory(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public <T extends Entity<?>> Repository<T> createRepository(Schema schema) {
        return new MysqlRepository<>(schema, jdbcTemplate);
    }
}
